//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.neurosky.thinkgear;

import java.util.List;

public class LinearInterpolation {
    private int a;
    private float b;
    private float[] c;
    private int d;

    public LinearInterpolation() {
    }

    public float[] interpolate(int[] var1, float[] var2, int[] var3) {
        this.a = 1;
        this.b = (var2[1] - var2[0]) / (float)(var1[1] - var1[0]);
        this.c = new float[var3.length];

        for(this.d = 0; this.d < var3.length; ++this.d) {
            if(var3[this.d] > var1[this.a] && this.a < var1.length - 1) {
                ++this.a;
                this.b = (var2[this.a] - var2[this.a - 1]) / (float)(var1[this.a] - var1[this.a - 1]);
            }

            this.c[this.d] = var2[this.a - 1] + this.b * (float)(var3[this.d] - var1[this.a - 1]);
        }

        return this.c;
    }

    public float[] interpolate(List var1, List var2, int[] var3) {
        this.a = 1;
        this.b = (((Float)var2.get(1)).floatValue() - ((Float)var2.get(0)).floatValue()) / (float)(((Integer)var1.get(1)).intValue() - ((Integer)var1.get(0)).intValue());
        this.c = new float[var3.length];

        for(this.d = 0; this.d < var3.length; ++this.d) {
            if(var3[this.d] > ((Integer)var1.get(this.a)).intValue() && this.a < var1.size() - 1) {
                ++this.a;
                this.b = (((Float)var2.get(this.a)).floatValue() - ((Float)var2.get(this.a - 1)).floatValue()) / (float)(((Integer)var1.get(this.a)).intValue() - ((Integer)var1.get(this.a - 1)).intValue());
            }

            this.c[this.d] = ((Float)var2.get(this.a - 1)).floatValue() + this.b * (float)(var3[this.d] - ((Integer)var1.get(this.a - 1)).intValue());
        }

        return this.c;
    }
}
